function [XD,YD]=p_rect(rx,ry)
% p_rect: Return the vertices of a rectangle
%
% SYNTAX:
%   [XD,YD] = p_rect(rx,ry)
%   [XY] = p_rect(rx,ry)
%   Return vertices of specified rectangle with x-axis radius rx and y-axis radius ry.

%   Author: Hongbin Ma
%   Last updated: 2009-6-2 with MATLAB 6.5
%   Problems or suggestions? Email me: mathmhb[at]163.com

if length(rx)==1,
    rx=[-rx,rx];
end;
if length(ry)==1,
    ry=[-ry,ry];
end;
XD=[rx(1),rx(2),rx(2),rx(1),rx(1)];
YD=[ry(1),ry(1),ry(2),ry(2),ry(1)];
%~ XD=[-rx,+rx,+rx,-rx,-rx];
%~ YD=[-ry,-ry,+ry,+ry,-ry];
if nargout<2,
    XD=[XD;YD]';
end;
